Using vim color schemes with Putty
I am using PuTTY in Windows to access a Unix box, and the Terminal-type string in PuTTY is set to xterm. I wanted to use Vim's color schemes. I tried many different things with no decent result until I found the following code in Vim's help. After inserting the following lines in my vimrc, I was able to use all the color schemes defined by Vim. For a 16-color display: if has("terminfo") let &t_Co=16 let &t_AB="\let &t_AF="\[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm" else let &t_Co=16 let &t_Sf="\[3%dm" let &t_Sb="\[4%dm" endif For an 8-color display: if &term =~ "xterm" if has("terminfo") let &t_Co=8 let &t_Sf="\[3%p1%dm" let &t_Sb="\[4%p1%dm" else let &t_Co=8 let &t_Sf="\[3%dm" let &t_Sb="\[4%dm" endif endif Alternative With the settings below, using :runtime syntax/colortest.vim shows all 23 colors as distinctly unique. Putty settings: Window, Colours :[x Allow terminal to specify ANSI colours :x Allow terminal to specify xterm 256-colour mode :x Bolded text is a different colour Settings in vimrc: if &term =~ "xterm" " 256 colors let &t_Co = 256 " restore screen after quitting let &t_ti = "\7\[r\let &t_te = "\[?47l\8" if has("terminfo") let &t_Sf = "\[3%p1%dm" let &t_Sb = "\[4%p1%dm" else let &t_Sf = "\[3%dm" let &t_Sb = "\[4%dm" endif endif See also *[[VimTip25|Color highlighting on telnet] *Desert color scheme with Vim in PuTTY Comments It is relatively easy to change the TERM setting PuTTY uses to set it to send it as "xterm-256color" (or install the full set of terminfo files and set it to the proper setting of "putty-256color". -- PuTTY doesn't support Techtronix mode and so is not fully xterm compatible.) In PuTTY this is changed in the Configuration in the Connection -> Data section. This is the same preferences page where you specify your auto-login username, so you should be visiting this page anyway. With your auto-login username specified, and public key authorization (which you should be using) and a key agent running (PuTTY's Pageant does this) you can select a host and log in without being prompted for username or password. With your TERM set to anything close to accurate, you can then leverage all 256 colors in other applications without manually tweaking the settings for every application. Steven Black 17:49, December 9, 2010 (UTC) ---- I often use PuTTY at work to connect to a solaris box which we use for compiling code. I have no admin rights, and no knowledge of how to set up terminfo, etc. I tried the PuTTY setting you give, but I just get a "using dumb terminal mode" message on login, and Vim has no colors. The 256-color workaround in this tip works fine. I don't like it, I'd rather do it "the right way" but sadly this may not be an option for me. Unless there's something I can do in my own user space to get the terminfo correct. --Fritzophrenic 19:28, December 9, 2010 (UTC) ---- Chances are your system doesn't use terminfo then. Try hardwiring your term option like this: :set term=builtin_xterm or :set term=builtin_ansi That should give you colors in putty. Your vim needs to be compiled with +builtin_term (+ or ++), though. Chrisbra 20:50, December 9, 2010 (UTC) ---- Thanks for the suggestion. I have +builtin_terms (not ++builtin_terms) but neither :set term=builtin_xterm nor :set term=builtin_ansi have any noticeable effect to enable colors, even when it is the first item in the .vimrc (after :set nocompatible). Since the hack in this tip does work for me, and I really don't know much about terminal configuration, I'm probably going to just leave it. --Fritzophrenic 14:24, December 10, 2010 (UTC) ---- : It works for me with putty. But I need to explicitly set :syntax on after setting 'term' to builtin_ansi. 13:20, December 11, 2010 (UTC) ---- Try to set Terminal-type string in putty (Connection->Data) to 'putty-256color'. That worked for me.